import launch
import launch_ros

from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():

    Plot_pkg_share_dir = get_package_share_directory('Plot')

    Plot_node = Node(
        package='Plot',
        executable='Plot',
        name='Plot',
        output='screen',
        parameters=[
        ],
    )
    topics = [
        "/double_array_topic/data[0]",  
        "/double_array_topic/data[1]",  
        "/double_array_topic/data[2]",  
        "/double_array_topic/data[3]",   
        "/double_array_topic/data[4]"   
    ]

    rqt_plot_cmd = launch.actions.ExecuteProcess(
        cmd=['ros2', 'run', 'rqt_plot', 'rqt_plot'] + topics,  # 替换成你实际要监控的话题
        output='screen'
    )
    rqt_plot_node = Node(
        package='rqt_plot',
        executable='rqt_plot',
        name='rqt_plot_node',
        arguments=[
            "/double_array_topic/data[0]",
            "/double_array_topic/data[1]",
            "/double_array_topic/data[2]",
            "/double_array_topic/data[3]",
            "/double_array_topic/data[4]"
        ],
        output='screen'
    )
    return LaunchDescription([
        Plot_node,
        # rqt_plot_cmd,
        rqt_plot_node
    ])
